package cem.agony.model;

import java.util.HashMap;
import java.util.Map;

public class SagStation
{
    private static int nextId = 0;
    private final int id;
    private String name;

    private final Map<Integer, Double> stationToDistance = new HashMap<Integer, Double>();

    public SagStation( String name )
    {
        this.id = nextId;
        nextId++;
        this.name = name;
    }

    public void addStation( int id, double distance )
    {
        this.stationToDistance.put( id, distance );
    }

    public void setStations( Map<Integer, Double> stations )
    {
        this.stationToDistance.clear();
        this.stationToDistance.putAll( stations );
    }

    public void removeStation( int station )
    {
        this.stationToDistance.remove( station );
    }

    public double getDistance( int station )
    {
        if ( !stationToDistance.containsKey( station ) )
        {
            return 0.0;
        }

        return stationToDistance.get( station );
    }

    public Map<Integer, Double> getDistances()
    {
        return stationToDistance;
    }

    public int getId()
    {
        return id;
    }

    public String getName()
    {
        return name;
    }

    public void setName( String name )
    {
        this.name = name;
    }
}